package com.guomao.controller;

import com.guomao.entity.Order;
import com.guomao.entity.Result;
import com.guomao.mapper.OrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.RequestEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.net.URI;
import java.util.Collection;
import java.util.List;

@Controller
public class MyControllerC {


    //RequestEntity 是springmvc框架提供的类
    @RequestMapping("/method1")
    public String method1(RequestEntity<String> entity) {

        String method_name = entity.getMethod().name();
//        String typeName = entity.getType().getTypeName();

        String url = entity.getUrl().toString();

        HttpHeaders headers = entity.getHeaders();

        String body = entity.getBody();

        System.out.println(method_name);
//        System.out.println(typeName);
        System.out.println(url);

        List<String> list = headers.get("User-Agent");
        System.out.println(list);
        System.out.println(body);

        return "main";
    }

    @RequestMapping("/method2")
    public ResponseEntity<String> method2() {
//    public ResponseEntity<byte[]> method2() {

        HttpHeaders headers = new HttpHeaders();
        headers.add("address", "fujianxiamen");

        String body = "<h1>ResponseEntity</h1>";

        HttpStatus ok = HttpStatus.OK;

        ResponseEntity<String> entity = new ResponseEntity<>(body, headers, ok);

        return entity;
    }
}
